}
mountdp() { # <device> <mount_point> <ignored> <fs>
- dev=$1; mnt=$2; shift 2; opt=$*
+ dev=$1; mnt=$2; shift 2; opt=$*
mount $dev $mnt $opt
dupe $mnt $rom
pivot $mnt /rom
}
+fopivot() { # <rw_root> <ro_root> <dupe?>
+ root=$1
+ {
+ mount -t mini_fo -o base=/,sto=$1 none /mnt 2>&- && root=/mnt
+ } || {
+ [ "$3" = "1" ] && mount -o bind $1 $1 && dupe $1 $rom
+ }
+ pivot $root $2
+}
+
ramoverlay() {
mkdir -p /tmp/root
- mountdp /tmp/root /mnt -o bind
+ fopivot /tmp/root /rom 1
}
[ "${0##*/}" = "firstboot" ] && {
[ "$1" = "switch2jffs" ] && {
mtd erase OpenWrt
- mount -o remount,ro none / # try to avoid fs changing while copying
- mount -o bind / /mnt
+ mount -o remount,ro none / 2>&- # try to avoid fs changing while copying
+ mount -o bind /tmp/root /mnt
mount /dev/mtdblock/4 /rom/jffs -t jffs2
echo -n "copying files ... "
cp -a /mnt/* /rom/jffs
echo "done"
pivot /rom /mnt
mount -o move /mnt /tmp/root
- pivot /jffs /rom
+ fopivot /jffs /rom
+ umount /tmp/root 2>&-
jffs2root --clean
exit 0
}